/* Copyright 2009 Requirements Management System 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.mags.remas.control;

import java.util.Map; 
import org.apache.commons.validator.GenericValidator;
import org.mags.remas.model.entity.EntityRelationship;

/**
 * 
 * @author Mario Gaitan
 *
 */
public class ListEditorInput extends RelationshipEditorInput {
	final private String[] properties;
	final private String[] titles;
	private String[] labels;
	private Map<String, Object[]> comboValues;

	public Map<String, Object[]> getComboValues() {
		return comboValues;
	}
	public void setComboValues(Map<String, Object[]> comboValues) {
		this.comboValues = comboValues;
	}
	public String[] getLabels() {
		return labels;
	}
	public void setLabels(String[] labels) {
		this.labels = labels;
	}
	public String[] getTitles() {
		return titles;
	}
	public String[] getProperties() {
		return properties;
	}
	private void assertVector(String[] vector) {
		if(vector==null)
			throw new RuntimeException("argument can't be null");
		for(String element: vector)
			if(GenericValidator.isBlankOrNull(element))
				throw new RuntimeException("element in vector can't be null");		
	}	
	public ListEditorInput(EntityRelationship entityRelationship, String[] properties, String[] titles, String className) {
		super(entityRelationship, className);
		assertVector(properties);
		assertVector(titles);
		this.properties = properties;
		this.titles = titles;
	}	
	public ListEditorInput(EntityRelationship entityRelationship, String[] properties, String[] titles) {
		super(entityRelationship, ListEditorInput.class.getName());
		assertVector(properties);
		assertVector(titles);		
		this.properties = properties;
		this.titles = titles;
	}
}
